home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Assembly Language Step by Step
/
Assembly Language Step by Step.mdf
/
ForDOS
/
ASM
/
SHOWCHAR.ASM
< prev
next >
Wrap
Assembly Source File
|
1999-12-12
|
3KB
|
55 lines
; Source name : SHOWCHAR.ASM
; Executable name : SHOWCHAR.COM
; Code model: : Real mode flat model
; Version : 1.0
; Created date : 9/18/1999
; Last update : 9/18/1999
; Author : Jeff Duntemann
; Description : A simple example of a DOS .COM file programmed for
; real mode flat model, using NASM 0.98 and ALINK.
; This program demonstrates how multi-line macros are
; used with NASM.
[BITS 16] ; Set 16 bit code generation
[ORG 0100H] ; Set code start address to 100h (COM file)
[SECTION .text] ; Section containing code
%include "MYLIB.MAC" ; Load in screen control macro library
START: ; This is where program execution begins:
Clear VidOrigin,0720H,4000 ; Clear full video buffer to spaces
; Show a 64-character rule above the table display:
Ruler VidOrigin,LineLen,ScrnWidth,0,LinesDown-1
les DI,[VidOrigin] ; Put vid seg in ES & offset in DI
add DI,ScrnWidth*LinesDown*2 ; Start table display down a ways
mov CX,256 ; There are 256 chars in the ASCII set
mov AX,0700H ; Start with char 0, attribute 7
DoLine: mov BL,LineLen ; Each line will consist of 64 characters
DoChar: stosw ; Note that there's no REP prefix!
jcxz AllDone ; When the full set is printed, quit
inc AL ; Bump the character value in AL up by 1
dec BL ; Decrement the line counter by one
loopnz DoChar ; Go back & do another char until BL goes to 0
add DI,(ScrnWidth - LineLen)*2 ; Move DI to start of next line
jmp DoLine ; Start display of the next line
AllDone: GotoXY 0,12 ; Move hardware cursor down below char. table
mov AH,4CH ; Terminate process DOS service
mov AL,0 ; Pass this value back to ERRORLEVEL
int 21H ; Control returns to DOS
[SECTION .data] ; Section containing initialised data
LRXY DW 184FH ; 18H = 24D; 4FH = 79D; 0-based XY of LR screen corner
VidOrigin DD 0B8000000H ; Change to 0B0000000H if you have a mono CRT!
CRLF DB 0DH,0AH
ScrnWidth EQU 80 ; Width of the screen in characters
LineLen EQU 64 ; Length of one line of the ASCII table
LinesDown EQU 4 ; Number of lines down to start ASCII table